home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / IAH3MU (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.4 KB  |  35 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Point;
  5. import java.awt.event.ActionEvent;
  6.  
  7. class DefaultEditorKit$BackwardAction extends TextAction {
  8.    private boolean select;
  9.  
  10.    DefaultEditorKit$BackwardAction(String nm, boolean select) {
  11.       super(nm);
  12.       this.select = select;
  13.    }
  14.  
  15.    public void actionPerformed(ActionEvent e) {
  16.       JTextComponent target = ((TextAction)this).getTextComponent(e);
  17.       if (target != null) {
  18.          int dot = target.getCaretPosition();
  19.          if (dot > 0) {
  20.             --dot;
  21.             if (this.select) {
  22.                target.moveCaretPosition(dot);
  23.             } else {
  24.                target.setCaretPosition(dot);
  25.             }
  26.          } else {
  27.             ((Component)target).getToolkit().beep();
  28.          }
  29.  
  30.          target.getCaret().setMagicCaretPosition((Point)null);
  31.       }
  32.  
  33.    }
  34. }
  35.